﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Xiezl.Common.Data;
using Xiezl.Common.Web.PgExp;
using Xiezl.Common.Entity;

/*
 * 作者: 谢中涞,博客园:http://www.cnblogs.com/xie-zhonglai
 * 欢迎转载,但请保留出处
 * */

namespace Xiezl.Common.Web.Controllers
{
    public class SysController : BaseController
    {
        private SysService sysService;
        protected SysService SysServices
        {
            get
            {
                if (sysService == null)
                    sysService = new SysService();
                return sysService;
            }

        }


        //
        // GET: /Sys/

        public ActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 查询产品列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetProductList()
        {
            string json = string.Empty;
            //if (WebRuntimes.LoginUser == null)
            //    return Content(GetAlertMessageJson("会话已过期,请重新登录"));
            try
            {
                //构件查询条件
                var queryParam = GetQueryParam<Product, PgQueryProductExp>();

                int total = 0;

                //查询数据
                var lst = SysServices.GetProductList(queryParam, out total);

                //将lst转化为jqgrid接受的json格式
                json = JsonForJqgrid(lst, total, queryParam.PageSize, queryParam.PageIndex);
            }
            catch (Exception ex)
            {
                //  Logger.Log(ELogType.Error, ex);
                json = GetAlertMessageJson("查询失败！");
            }

            return Content(json);
        }

        /// <summary>
        /// 返回产品品种下拉列表json字符串 略
        /// </summary>
        /// <returns></returns>
        public string GetProductCategoryComboxJson()
        {
            return "[]";
        }
    }
}
